from tools.dbo import get_server_data_car, put_mysql_data, get_server_data, carried_sql, get_server_data_one


def syn_sample_out_stock_bill(sql_server_conn, mysql_conn):

    return_data = get_server_data(sql_server_conn,
                                  "billNo,outStockReason,applyDepartId+99,applyEmpId,isRemberFreezeCount,isKeepPosition,mark,isrtEmpId,isrtDt,updtEmpId,updtDt", "isDel = 0",
                                  "AP_SP_SampleOutStockBill")
    print(put_mysql_data(mysql_conn, "code,reason_name,dept_id,apply_user_id,record_freeze_times,keep_position,remark,create_id,create_time,update_id,update_time", "sample_store_out", return_data))

def syn_sample_out_stock_bill_detail(sql_server_conn, mysql_conn):

    return_data = get_server_data(sql_server_conn,
                                  "billNo,sampleId,outFromContainerPosition,useCapacity,scanDt,scanEmpId","1=1",
                                  "AP_SP_SampleOutStockDetail")
    print(put_mysql_data(mysql_conn, "code,sample_id,storage_coordinates,use_capacity,create_time,create_id", "sample_store_out_detail", return_data))

def syn_sample_destory_bill(sql_server_conn, mysql_conn):

    return_data = get_server_data(sql_server_conn,
                                  "billNo,destroyReason,applyDepartId+99,applyEmpId,mark,isrtEmpId,isrtDt,updtEmpId,updtDt,5,isrtDt,isrtDt", "1=1",
                                  "AP_SP_SampleDestroyBill")
    print(put_mysql_data(mysql_conn, "code,reason_name,dept_id,apply_user_id,remark,create_id,create_time,update_id,update_time,state,destroy_time,apply_time", "sample_destroy", return_data))

def syn_sample_destory_bill_detail(sql_server_conn, mysql_conn):

    return_data = get_server_data(sql_server_conn,
                                  "billNo,sampleId,outFromContainerId,outFromContainerPosition","1=1",
                                  "AP_SP_SampleDestroyDetail")
    print(put_mysql_data(mysql_conn, "code,sample_id,storage_location,storage_coordinates", "sample_destroy_detail", return_data))